package com.chenwut.Exercise;

import java.util.Scanner;

class Person {
    public void haveLesson() {
        System.out.println("上课...");
    }
}

class Teacher extends Person {
    public Teacher(String name) {
        System.out.print(name);
    }

    public void haveLesson() {
        System.out.println( "在授课");
    }
}

class Student extends Person {
    public Student(String name) {
        System.out.print(name);
    }

    public void haveLesson() {
        System.out.println("在听课");
    }
}

public class Main {
    public static void main(String[] args) {
        String tname, sname;
        Scanner in = new Scanner(System.in);
        System.out.print("请输入老师姓名：");
        tname = in.nextLine();
        System.out.print("请输入学生姓名：");
        sname = in.nextLine();
        doLesson(new Teacher(tname));
        doLesson(new Student(sname));
    }

    public static void doLesson(Person e) {
        e.haveLesson();
    }
}